package com.wis.kafka_test;

import org.apache.kafka.clients.admin.AdminClient;
import org.apache.kafka.clients.admin.KafkaAdminClient;
import org.apache.kafka.clients.admin.ListTopicsResult;
import org.apache.kafka.clients.admin.TopicListing;
import org.apache.kafka.clients.consumer.KafkaConsumer;
import org.apache.kafka.common.KafkaFuture;
import org.junit.Test;

import java.util.*;
import java.util.concurrent.ExecutionException;

/**
 * @Description: traffic_wis
 * @author: fan
 * @Date: Created in 2019/3/21 12:28
 * @Modified By:
 */
public class Kafak_test {
    @Test
    public void test() throws ExecutionException, InterruptedException {
        Properties props = new Properties();
        props.put("bootstrap.servers", "10.40.17.99:9092,10.40.17.100:9092");
        // props.put("bootstrap.servers", "traefik-kafka:80");
        props.put("group.id", "risk321");
        props.put("enable.auto.commit", "true");
        props.put("auto.commit.interval.ms", "1000");
        props.put("auto.offset.reset", "latest");
        props.put("key.deserializer", "org.apache.kafka.common.serialization.StringDeserializer");
        props.put("value.deserializer", "org.apache.kafka.common.serialization.StringDeserializer");
        KafkaConsumer<String, String> consumer = new KafkaConsumer<>(props);
        System.out.println(consumer.listTopics().keySet());
    }
}
